package objetsBd;

import java.io.Serializable;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author verpoorten
 */
@Entity
@Table(name = "Personne")
public class PersonneBd implements Serializable,Cloneable {

    private static final Logger LOGGER = Logger.getLogger(PersonneBd.class.getName());
    private static final long serialVersionUID = 1L;
    private static final String SEQ_ID = "idPersonne_sequence ";
    @Id
    @SequenceGenerator(name = SEQ_ID,
            sequenceName = SEQ_ID, allocationSize = 1)
    @GeneratedValue(generator = SEQ_ID)
    @Column(name = "idPersonne")
    private Long idPersonne;
    @Column(name = "nom")
    private String nom;
    @Column(name = "prenom")
    private String prenom;
    @Column(name = "email")
    private String email;
    @Column(name = "profession")
    private String profession;
    @Column(name = "civilite")
    private String civilite;
    @Column(name = "dateDeNaissance")
    @Temporal(TemporalType.DATE)
    private Date dateDeNaissance;
    @Column(name = "lieuDeNaissance")
    private String lieuDeNaissance;
    @Column(name = "numCarteIdentite")
    private String numCarteIdentite;
    @Column(name = "tel")
    private String tel;
    @Column(name = "gsm")
    private String gsm;

    public static PersonneBd parNomLocataire(String petName) {
        LOGGER.log(Level.INFO, "PersonneBd parNomLocataire");
        PersonneBd locataire = new PersonneBd();
        locataire.setNom(petName);
        return locataire;
    }

    public static PersonneBd parIdPersonne(Long idDepense) {
        PersonneBd locataire = new PersonneBd();
        locataire.setIdPersonne(idDepense);
        return locataire;
    }

    public Long getIdPersonne() {
        return idPersonne;
    }

    public void setIdPersonne(Long idPersonne) {
        this.idPersonne = idPersonne;
    }

    public String getNom() {
        return nom;
    }

    public void setNom(String nom) {
        this.nom = nom;
    }

    public String getPrenom() {
        return prenom;
    }

    public void setPrenom(String prenom) {
        this.prenom = prenom;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getProfession() {
        return profession;
    }

    public void setProfession(String profession) {
        this.profession = profession;
    }

    public String getCivilite() {
        return civilite;
    }

    public void setCivilite(String civilite) {
        this.civilite = civilite;
    }

    public Date getDateDeNaissance() {
        return dateDeNaissance;
    }

    public void setDateDeNaissance(Date dateDeNaissance) {
        this.dateDeNaissance = dateDeNaissance;
    }

    public String getLieuDeNaissance() {
        return lieuDeNaissance;
    }

    public void setLieuDeNaissance(String lieuDeNaissance) {
        this.lieuDeNaissance = lieuDeNaissance;
    }

    public String getNumCarteIdentite() {
        return numCarteIdentite;
    }

    public void setNumCarteIdentite(String numCarteIdentite) {
        this.numCarteIdentite = numCarteIdentite;
    }

    public String getTel() {
        return tel;
    }

    public void setTel(String tel) {
        this.tel = tel;
    }

    public String getGsm() {
        return gsm;
    }

    public void setGsm(String gsm) {
        this.gsm = gsm;
    }

    public String getPrenomNom() {
        String prenomNom = "";
        if (prenom != null) {
            prenomNom = prenom;
        }
        if (prenom != null && nom != null) {
            prenomNom += " ";
        }
        if (nom != null) {
            prenomNom += nom;
        }
        return prenomNom;
    }
    
    public PersonneBd createClone() {
        try {
            return (PersonneBd) super.clone();
        } catch (CloneNotSupportedException ex) {
            throw new IllegalStateException(ex);
        }
    }
}
